import request from '@/utils/request';

interface LoginParams {
  phone: number | string;
  password?: string;
  code2?: number;
}

interface userParams {
  phone?: number | string;
  page?: string;
  size?: number;
}

// 登录接口
export const loginApi = (data: LoginParams) =>
  request<{
    data: string;
  }>({
    url: '/admin/auth/login',
    method: 'post',
    data
  });

// 获取验证码
export const codeApi = (data: LoginParams) =>
  request<{
    data: string;
  }>({
    url: '/main/auth/phone',
    method: 'post',
    data
  });

// 验证码登录
export const codeLoginApi = (data: LoginParams) =>
  request<{
    data: string;
  }>({
    url: '/main/auth/login',
    method: 'post',
    data
  });

// 获取用户信息
export const myInfoApi = () =>
  request<{
    data: any;
  }>({
    url: '/zh/side/user'
  });

  // 获取用户列表
  export const userListApi = (data: any) =>
  request<{
    data: any;
  }>({
    url: '/zh/side/fb',
    params: {...data}
  });

  // 管理用户列表
  export const userAdminApi = (data: any) =>
  request<{
    data: any;
  }>({
    url: '/zh/side/yh',
    params: {...data}
  });

  export const stateAdminApi = (data: any) =>
  request<{
    data: string;
  }>({
    url: '/zh/side/gl',
    method: 'post',
    data
  });

  export const stateUserApi = (data: any) =>
  request<{
    data: string;
  }>({
    url: '/zh/side/modify',
    method: 'post',
    data
  });

  // 获取权限
  export const authorityApi = () =>
  request<{
    data: any;
  }>({
    url: '/zh/side/right'
  });

  // 获取用户下的权限
  export const authorityUserApi = (data: any) =>
  request<{
    data: any;
  }>({
    url: '/zh/side/right2',
    params: data
  });


  // 分配权限
  export const shareAuthorityApi = (data: any) =>
  request<{
    data: string;
  }>({
    url: '/zh/side/mate',
    method: 'post',
    data
  });

  // 新增角色
  export const addRoleApi = (data: any) =>
  request<{
    data: string;
  }>({
    url: '/zh/side/login',
    method: 'post',
    data
  });

  // 修改角色
  export const uploadRoleApi = (data: any) =>
  request<{
    data: string;
  }>({
    url: '/zh/side/info',
    method: 'post',
    data
  });

  // 删除角色
  export const delRoleApi = (data: any) =>
  request<{
    data: string;
  }>({
    url: '/zh/side/sc',
    method: 'post',
    data
  });
